﻿
Partial Class Login
    Inherits System.Web.UI.Page

    Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs)
        'There was a problem logging in the user

        'See if this user exists in the database
        Dim userInfo As MembershipUser = Membership.GetUser(Login1.UserName)

        If Not userInfo Is Nothing Then
            'See if the user is locked out or not approved
            If Not userInfo.IsApproved Then
                LoginErrorDetails.Text = "Votre compte n'a pas encore été activé. Réessayez plus tard."
            ElseIf userInfo.IsLockedOut Then
                LoginErrorDetails.Text = "Votre compte a été verrouillé à cause d'un trop grand nombre de tentatives d'identification. Contactez un administrateur système pour déverrouiller votre compte."
            Else
                'The password was incorrect (don't show anything, the Login control already describes the problem)
                LoginErrorDetails.Text = String.Empty
            End If
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.QueryString("ReturnUrl") = "" Or Request.QueryString("ReturnUrl") = "Login.aspx" Then
            Response.Redirect("Default.aspx")
        End If

        If HttpContext.Current.User.Identity.IsAuthenticated = True Then
            Response.Redirect("/Default.aspx")
        End If
    End Sub
End Class
